/**
* 版权所有：福建邮科电信业务部厦门研发中心 
*====================================================
* 文件名称: TestMain.java
* 修订记录：
* No    日期				作者(操作:具体内容)
* 1.    2013-4-10			詹保山(创建:创建文件)
*====================================================
* 类描述：(说明未实现或其它不应生成javadoc的内容)
* 
*/
package zbs.example;

import java.io.File;
import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.util.ClassUtils;

import com.devframe.component.ftlprocess.MyFTLProcessContextContainer;
import com.devframe.component.ftlprocess.cache.MyFTLProcessCacheManager;
import com.devframe.component.ftlprocess.engine.MyFTLProcessEngine;
import com.devframe.component.ftlprocess.meta.AskData;

public class TestMain {
static	ApplicationContext appCtx=new ClassPathXmlApplicationContext("spring-myreport.xml");
	
	static String clazzName="zbs.example.TestServiceBean";
		static{
			try {
				Object obj=ClassUtils.forName(clazzName,appCtx.getClassLoader()).newInstance();
				TestServiceBean obj1=(TestServiceBean)appCtx.getAutowireCapableBeanFactory().autowire(ClassUtils.forName(clazzName,appCtx.getClassLoader()), 1, true);
				 System.out.println(obj1.getDataList());
				 MyFTLProcessCacheManager.putCacheOfServiceBean("testServiceBean", obj1);
			
			} catch (BeansException e) {
				e.printStackTrace();
			} catch (IllegalStateException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			} catch (Exception e) {
				e.printStackTrace();
			}			
		}

		
	
static class  My extends Thread{
	public void run() {
		AskData askData=new AskData();
		askData.setTemplateFile("d.ftl");
		Map<String,Object> params=new HashMap<String,Object>();
		askData.setParams(params);
		MyFTLProcessEngine engine=(MyFTLProcessEngine)appCtx.getBean("ftlProcessDefaultEngine");
		Writer writer=new StringWriter();
		engine.execEngine(askData, writer);
		System.out.println(writer);
		System.out.println();
	}
}
	/**
	 * @param args
	 * @author:詹保山
	 */
	public static void main(String[] args) {

		 
		
		
		
		for(int i=0;i<100;i++){
			My my=new My();
			my.run();
//			System.out.println(MyFTLProcessCacheManager.getCacheOfModel("d.ftl"));			
		}

		
		
		
		
 
//		askData.setTemplateFile("e.ftl");
//		 writer=new StringWriter();
//		
//		engine.execEngine(askData, writer);
//		System.out.println(writer);
//		
//		
//		askData.setTemplateFile("e.ftl");
//		 writer=new StringWriter();
//		
//		engine.execEngine(askData, writer);
//		System.out.println(writer);
//		
		
		
		
	}
	
	

}
